"""
    运算符重载
"""

class Vector1:
    """通过重载实现，对象进行相加"""
    def __init__(self, x):
        self.x = x
    
    def __str__(self):
        """
            字符串重载，输出字符串，不要输出对象名字和地址
        """
        return f"x值是：{self.x}"
    
    #%% 加减乘除，地板除，平方重载
    def __add__(self, other):
        """加法重载"""
        return Vector1(self.x + other)
    def __sub__(self, other):
        """
            减法重载
        """
        return Vector1(self.x - other)
    def __mul__(self, other):
        """
            乘法法重载
        """
        return Vector1(self.x * other)
    def __truediv__(self, other):
        """除法重载"""
        return Vector1(self.x / other)
    def __floordiv__(self, other):
        """地板除重载"""
        return Vector1(self.x // other)
    def __mod__(self, other):
        """取余重载"""
        return Vector1(self.x % other)
    def __pow__(self, other):
        """平方重载"""
        return Vector1(self.x ** other)
    
    #%% 反向 加减乘除，地板除，平方重载
    def __radd__(self, other):
        """加法重载"""
        return Vector1(self.x + other)
    def __rsub__(self, other):
        """
            减法重载
        """
        return Vector1(self.x - other)
    def __rmul__(self, other):
        """
            乘法法重载
        """
        return Vector1(self.x * other)
    def __rtruediv__(self, other):
        """除法重载"""
        return Vector1(self.x / other)
    def __rfloordiv__(self, other):
        """地板除重载"""
        return Vector1(self.x // other)
    def __rmod__(self, other):
        """取余重载"""
        return Vector1(self.x % other)
    def __rpow__(self, other):
        """平方重载"""
        return Vector1(self.x ** other)

ls = Vector1(10)
print(42 * ls)


    